package com.student.controller;

import com.student.model.Room;
import com.student.service.RoomService;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("room")
public class RoomController {
    @Autowired
    private RoomService roomService;
    //通过Id获取房间信息
    @GetMapping("get")
    public Room getInforById (@RequestParam("id") Integer RoomId){
        return roomService.getInforById(RoomId);
    }
    //新增房间
    @PostMapping("insert")
    public int insertRoom (@RequestBody Room room){
        return roomService.insertRoom(room);
    }
    //通过Id删除房间
    @DeleteMapping("delete")
    public int deleteInforById (@RequestParam("id") Integer RoomId){
        return roomService.deleteInforById(RoomId);
    }
    //查询所有房间
    @GetMapping("all")
    public List<Room> getAllRooms(){
        return roomService.getAllRooms();
    }
    //修改房间信息
    @PutMapping("put")
    public int putRoomInfo(@RequestBody Room room){
        int count = roomService.putRoomInfo(room);
        return count;
    }
    //批量添加房间信息
    @PostMapping("batch")
    public int insertBatchRoom(@RequestBody List<Room> rooms){
        return roomService.insertBatchRoom(rooms);
    }
    //批量删除房间
    @DeleteMapping("batchDelete")
    public int deleteBatchRoom(@RequestBody List<Integer> roomIds){
        return roomService.deleteBathRoom(roomIds);
    }
    //通过房间Id查询学生信息
    @GetMapping("roomstudent")
    public List<Room> getRoomIncludeStudentInfoById (@RequestParam("id")Integer roomId){
        return roomService.getRoomIncludeStudentInfoById(roomId);
    }
}
